package com.ja.openchat.ui.me;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import androidx.annotation.Nullable;

import com.ja.openchat.BR;
import com.ja.openchat.R;
import com.ja.openchat.databinding.FragmentCollectionRecordBinding;
import com.ja.openchat.viewmodels.CollectionRecordViewModel;

import me.goldze.mvvmhabit.base.BaseFragment;
import me.goldze.mvvmhabit.utils.KLog;

//收款记录界面
public class CollectionRecordFragment extends BaseFragment<FragmentCollectionRecordBinding, CollectionRecordViewModel> {

    @Override
    public int initContentView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return R.layout.fragment_collection_record;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public void initView() {
        binding.refreshLayout.setEnableLoadMore(false);
    }

    @Override
    public void initData() {
        binding.refreshLayout.autoRefresh();
    }

    @Override
    public void initViewObservable() {
        //监听下拉刷新完成
        viewModel.uc.finishRefreshing.observe(this, o -> {
            //结束刷新
            binding.refreshLayout.finishRefresh();
        });
        //监听上拉加载完成
        viewModel.uc.finishLoadmore.observe(this, o -> {
            //结束刷新
            binding.refreshLayout.finishLoadMore();
        });
        //监听是否启用加载更多
        viewModel.uc.enableFinishLoadmore.observe(this, aBoolean -> {
            KLog.d("enableFinishLoadmore==" + aBoolean);
            binding.refreshLayout.setEnableLoadMore(aBoolean);
        });
    }
}